package com.maopuyu.controllers;

import com.maopuyu.utils.CommonUtils;
import com.maopuyu.utils.RequestUtils;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping(value = "/api/m3u8")
@CrossOrigin
public class M3u8Controller {
    @RequestMapping(value = "", method = RequestMethod.GET)
    public String httpGetM3u8(@RequestParam("uri") String m3u8Uri, @RequestParam("headerParams") String headerParams) {
        return RequestUtils.sendRequest(m3u8Uri, CommonUtils.Json2Mapper(headerParams));
    }


    @RequestMapping(value = "/ts", method = RequestMethod.GET)
    public byte[] httpGetTs(@RequestParam("uri") String tsUri) {
        String real_uri = "http://livenging.alicdn.com/mediaplatform/" + tsUri;
        return RequestUtils.sendByteRequest(real_uri);
    }
}
